package ks.managers.game;

import java.util.Hashtable;

/**
 * Manages a set of games.
 * <p>
 * This manager can be used on either client or server.
 * 
 * @author Daphne Gorman
 * @author harry moreno
 */

public class GameManager {
	
	protected Hashtable<Integer, Game> knownGames = new Hashtable<Integer, Game>();
	
	/**
	 * Protect access to constructor.
	 */
	public GameManager() {}
	
	/**
	 * Retrieve individual game by name from the store of games.
	 * 
	 * @param int num Game Number
	 * @return the game that corresponds to that int
	 */
	public Game getGame(int num) {
		return knownGames.get(new Integer(num));
	}

	/**
	 * Add game to the store of games.
	 * 
	 * @param game The Game to add to the store of users.
	 * @return true on success.
	 */
	public boolean addGame (int table, Game game) {
		if (knownGames.get(new Integer(table)) != null)
			knownGames.remove(new Integer(table));
		
		knownGames.put(new Integer(table), game);
		
		return true;
	}
	/** clear away all games */
	public boolean removeAll(){
		knownGames.clear();
		return true;
	}
	/** remove a particular game */
	public boolean remove(int table){
		knownGames.remove(new Integer(table));
		return true;
	}
}
